def str_rank_combination(s=""):
    """输入一个字符串，返回一个由这些字符组成的排列组合（递归思想）"""
    if len(s) <= 1:  # 递归出口
        return [s]
    else:
        str_list = []
        for i in range(len(s)):
            for tmp_str in str_rank_combination(s[:i] + s[i + 1:]):
                str_list.append(s[i] + tmp_str)
        return str_list


if __name__ == "__main__":
    s = input('请输入字符串：')
    s = ''.join(set(s))  # 去除重复元素
    str_list = str_rank_combination(s)
    print("排列组合数：%d" % len(str_list))
    print("排列组合数明细：%s" % str(str_list))


# def mergeMinValue(lst):
#     import functools
#     # 生成字符串列表
#     lst = list(map(str, lst))
#     lst.sort(key=functools.cmp_to_key(lambda x, y: int(x+y) - int(y+x)))
#     # 数字进行拼接
#     result = ''.join(lst)
#     # 返回结果
#     return result
#
#
# if __name__ == "__main__":
#     sum_number = int(input('请输入数字个数：'))
#     number = []
#     for i in range(sum_number):
#         number.append(input('请输入第{}个数字：'.format(i + 1)))
#     s = mergeMinValue(number)
#     print('{}组合的最小数值是{}'.format(number,s))
# import functools
# def minNumber(strs):
#     def sort_rule(x, y):#比较函数
#         a, b = x + y, y + x
#         if a > b:
#             return 1
#         elif a < b:
#             return -1
#         else:
#             return 0
#
#     #生成字符串列表
#     # strs = [str(num) for num in nums]
#     #排序
#     strs.sort(key=functools.cmp_to_key(sort_rule))
#     return ''.join(strs)
# if __name__ == "__main__":
#     sum_number = int(input('请输入数字个数：'))
#     number = []
#     #生成字符串列表
#     for i in range(sum_number):
#         number.append(input('请输入第{}个数字：'.format(i + 1)))
#     #返回字符串
#     s = minNumber(number)
#     print('{}组合的最小数值是{}'.format(number,s))